package edu.gatech.arktos;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;


public class Student {
	String id, name, attend, email;
	List<Assignment> assignments;
	int avgGrade;
	
	
	/**
	 * Constructor
	 */

	public Student(String id, String name, String attend, List<Assignment> assignments, int avgGrade, String emailAdd){
		this.id = id;
		this.name = name;
		this.attend = attend;
		this.assignments = assignments;
		this.avgGrade = avgGrade;
		this.email = emailAdd;
	
	}
	
	/**
	 * Getter for students id
	 * @return id - String
	 */
	public String getGtid(){
		return this.id;
	}
	
	/**
	 * Getter for the students attendance
	 * @return attend - int
	 */
	public int getAttendance(){
		double temp  = Double.parseDouble(attend);
		
		return ((int)temp);
	}
	
	/** 
	 * Getter for the students name
	 * @return
	 */
	public String getName(){
		
		return this.name;
	}
	
	/**
	 * Getter
	 * @param a - assignment
	 * @return grade - student grade
	 * @author Daranhdara Hun
	 */
	public int getGradeForAssignment(Assignment a){
		String assName = a.getName();
		if (assName.compareTo("Assignment 1")==0){
			return assignments.get(0).getGrade();
		}
		else if(assName.compareTo("Assignment 2")==0){
			return assignments.get(1).getGrade();
		}
		else if(assName.compareTo("Assignment 3")==0){
			return assignments.get(2).getGrade();
		}
		return 0;
	}
	
	/**
	 * Getter
	 * @return assignments
	 * @author Daranhdara Hun
	 */
	public List<Assignment> getListOfAssignments(){
		return this.assignments;
	}
	
	/**
	 * 
	 * @return
	 * @author Daranhdara Hun
	 */
	public int getAvgGrade(){
		return this.avgGrade;
	}
	
	public String getEmail(){
		return this.email;
	}



	
	

	/**
	 * 
	 * @author Daranhdara Hun
	 */
	public void saveInfoToFile() {
		FileWriter outFile;
		PrintWriter out;
		try {
			outFile = new FileWriter("ErnestaAnderson.txt");
			out = new PrintWriter(outFile); 
			out.println("ID: "+this.id);
			out.println("Name: "+this.name);
			out.println("Attendance: "+this.attend);
			out.println("Email: "+this.email);
			out.println("Average Grade: "+this.avgGrade);
			out.close();
	
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		
	}
}
